<template>
  <div>
    <h2 @click="printMsg">子组件{{count}}</h2>
  </div>
</template>

<script setup>
import { provide } from 'vue';

// 定义子组件方法
const childMethod = () => {
  console.info("childMethod")
};

const printMsg = () => {
  console.info("childMethod")
  count.value=count.value+1;
};

defineExpose({
  childMethod,printMsg
});
import { inject } from 'vue';
const count = inject('count');
// 使用 provide 提供子组件方法给父组件
</script>
